Microcontrolled battery charger

ABSTRACT

A battery charger for use with different types of batteries, such as batteries requiring constant current charging, such as nickel cadmium (NiCd) and nickel metal hydride (NiMH) batteries, as well as batteries which not only require constant current charging, but also require constant voltage charging, such as lithium ion batteries. The battery charger includes a pulse width modulator circuit for controlling a power transistor to provide a constant current or a constant voltage output as a function of the battery characteristics. The battery charger may include dual pockets for charging two modular batteries on a time division multiplex basis. In the dual pocket application, power is divided between the two pockets as a function of the charging characteristics of the battery and the power dissipation of the power transistors used for supplying charging current to the pockets.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a battery charger and, moreparticularly, to a battery charger for providing both constant currentand constant voltage outputs suitable for charging batteries requiringconstant current charging, such as nickel--cadmium (NiCd) and nickelmetal hydride (NiMH), as well as batteries requiring both constantcurrent and constant voltage charging, such as lithium ion batteries.The battery charger includes a pulse width modulator (PWM) forcontrolling a power transistor to provide a constant current or aconstant voltage output to the battery being charged as a function ofthe battery characteristics. The battery charger may include dualpockets for charging two modular batteries at a time. In the dual pocketapplication, charging is divided between the two pockets on a time slicebasis. In such a configuration, the power dissipation of the powersupply and the power transistors used for supplying charging current tothe pockets is monitored and controlled.

2. Description of the Prior Art

Various portable devices and appliances, such as cellular phones,require rechargeable batteries. Various types of rechargeable batteriesare known to be used in such applications. For example, nickel--cadmium(NiCd), nickel metal hydride (NiMH), as well as lithium ion batteriesare known to be used. Because of the different charging characteristicsof such batteries, different battery chargers are required. For example,both nickel--cadmium (NiCd), as well as nickel metal hydride (NiMH),require constant current charging. On the other hand, lithium ionbatteries require constant current charging up to a certain voltagevalue and constant voltage charging thereafter. Because of the differentcharging requirements, different charging circuits are often required.

Standard battery packs normally consist of one or more battery cellsdisposed in a modular housing with external contacts for easy andconvenient coupling with the portable device in which it is used. Smartbattery packs, in addition to the battery cells, normally include amemory storage device which contains information regarding thecharacteristics of the battery as well as the battery type. Some smartbattery packs are known to include a microcontroller which allowscommunication by way of a bi-directional communication line with thebattery charger regarding various battery characteristics. Examples ofsuch smart battery packs are disclosed in: "Smart BatterySpecifications", ®1993 Duracell Inc., Intel Corporation, herebyincorporated by reference. Because of the differences between thestandard battery packs and the smart battery packs, different chargersare used for the smart battery packs and the standard battery packs.

Battery chargers for charging batteries which require constant currentcharging and batteries which require constant current and constantvoltage charging, such as lithium batteries, are known in the art.Battery chargers are also known that are adapted to automatically sensethe type of battery connected to the battery charger and provide theappropriate charging characteristic. As mentioned above, such batterychargers are used for various portable devices, such as cellular phones.Cellular phone battery chargers are commonly available as single pocketand dual pocket devices. Dual pocket devices are known to be used forcharging a spare battery, as well as the battery connected to thecellular phone. Unfortunately, with known dual pocket battery chargers,each pocket is known to be treated independently. In particular, insituations in which batteries to be charged are disposed in bothpockets, the battery in the active pocket is normally fully chargedbefore any servicing of the battery in the other pocket is done. Lithiumion batteries are known to take 3-4 hours to charge. Should a secondbattery be placed in the inactive pocket while a lithium battery isbeing charged in an active pocket, the second battery could remain inthe inactive pocket for 3-4 hours before charging is even commenced. Ifthe second battery also happens to be a lithium battery, it could takefrom 6-8 hours for the second battery to be charged from the time thesecond battery is inserted in the inactive pocket. Unfortunately, theend user will normally not be aware of such a limitation in the chargingsystem.

SUMMARY OF THE INVENTION

It is an object of the present invention to provide a battery chargerthat solves various problems in the prior art.

It is yet another object of the present invention to provide a batterycharger that is adapted for use with various types of batteries, such asnickel cadmium (NiCd), nickel metal hydride (NiMH), as well as lithiumion.

It is yet another object of the present invention to provide a batterycharger having a relatively simple circuit for providing constantcurrent and/or constant voltage charging.

It is yet another object of the present invention to provide a dualpocket battery charger which alternatively charges batteries in the twopockets on a time slice basis.

It is yet another object of the present invention to provide a dualpocket battery charger in which the charging is controlled as a functionof the power dissipation.

Briefly, the present invention relates to a battery charger that can beused with different types of batteries, such as batteries requiringconstant current charging, such as nickel cadmium (NiCd) and nickelmetal hydride (NiMH) batteries, as well as batteries which not onlyrequire constant current charging, but also require constant voltagecharging, such as lithium ion batteries. The battery charger includes apulse width modulator (PWM) for controlling a power transistor toprovide a constant current or a constant voltage output as a function ofthe battery characteristics. The battery charger may include dualpockets for charging two modular batteries at a time. In the dual pocketapplication, charging is divided between the two pockets on a timedivision multiplex basis as a function of the charging characteristicsof the battery and the power dissipation of the power supply and thepower transistors used for supplying charging current to the pockets.

BRIEF DESCRIPTION OF THE DRAWING

These and other objects of the present invention will be readilyunderstood with reference to the following specification and attacheddrawing, wherein:

FIG. 1 is a block diagram of the battery charger in accordance with thepresent invention.

FIG. 2 is a schematic diagram of a power supply and AC adapter for usewith the present invention.

FIGS. 3A and 3B are a schematic diagrams of the battery charging circuitfor the battery charger in accordance with the present invention.

FIGS. 4-15 are flow diagrams for the battery charger in accordance withthe present invention.

DETAILED DESCRIPTION OF THE INVENTION

The battery charger in accordance with the present invention isgenerally identified with the reference numeral 20 and includes abattery charger circuit 22. As shown and illustrated herein, the batterycharger 20 includes dual pockets, a front pocket 24 and a rear pocket26.

An important aspect of the invention is that the battery charger isadapted to charge batteries in both pockets 24, 26 on a time divisionmultiplex basis without waiting for the battery in one pocket to befully charged. In particular, each pocket 24, 26 is alternativelyserviced for a time slice, i.e., 62.5 microseconds. During servicing ofthe two pockets 24, 26, power dissipation measurements for the powersupply 28 and the power transistors Q₁ and Q₄ (discussed below) are madeevery interrupt cycle, i.e., 244 μsec. Should the power dissipation ofeither the power supply or the power transistors Q₁ and Q₄ exceedacceptable levels, the charging current is controlled to cause the powerdissipation to be within acceptable limits, as discussed in detailbelow.

As used herein, the "F" and "R" prefixes in the signal names refer tothe front and rear pockets 24 and 26, respectively. The signals -BATT+and -GND are used to provide the charging to any modular battery packsinstalled in the front pocket 24 or rear pocket 26. The battery voltageVBATT of the battery installed in the front and rear pockets 24, 26 isread by way of the -BATT+ signal. Certain batteries require that therate of change of temperature over time of the battery be maintainedwithin a certain range. Such battery packs are normally provided with athermistor for the purpose of reading the temperature of the batterypack. As such, both the front pocket 24 and rear pocket 26 are providedwith a -THERM signal for reading the thermistor value of the batterypacks with integral thermistors. The -COMM and -SIZE signals, providedbetween the battery charger circuit 22 and the front and rear pockets24, 26, are used with certain battery packs which provide a signalindicating the size of the battery or with other battery packs thatenable bi-directional communication between the battery pack and thebattery charger. As will be discussed in more detail below, the batterycharger circuit 22 reads the -SIZE and -COMM signals to determine thesize and/or type of battery in the front and rear pockets 24 and 26.Normally, only one of these signals, -SIZE or -COMM is provided with aparticular battery pack. The -SIZE signal merely identifies the size ofthe battery to the battery charger circuit 22. The -COMM signal isnormally used with battery packs which include an internal memorystorage device, such as an electrically erasable programmable read onlymemory (EEPROM). Such integral EEPROMs are known to be provided withlithium ion modular battery packs which provide various information,including information that the battery is a lithium ion battery.

POWER SUPPLY AND AC ADAPTER

As mentioned above, the battery charger circuit 22 is adapted to beutilized with a power supply 28, for example, a switching or linearpower supply, and an AC adapter 28. For example, the AC adapter mayinclude a step-down transformer T, (FIG. 2) with its primary windingadapted to be connected to a 120/240 VAC voltage supply. A conventionalrectifier RECT, for example, a full-wave bridge rectifier circuit,electrically coupled to the secondary winding of the transformer T₁,converts the unregulated AC voltage at the transformer secondary windingto an unregulated DC voltage. The unregulated DC voltage is input to aDC--DC converter circuit as described and illustrated below. Varioustypes of DC--DC converter circuits are suitable for use with the batterycharger 20 in accordance with the invention.

As shown in FIG. 1, the power supply 28 includes three terminals; P₁, P₂and P₃. The P₁ terminal is used for charging batteries in the front andrear pockets 24 and 26 while the P₃ terminal is used for system ground.The P₂ terminal is used for monitoring the battery voltage of thebatteries installed in the front and rear pockets 24 and 26,respectively. If batteries are installed in both the front and rearpockets 24 and 26, respectively, the battery with the highest voltagewill control the operation of the power supply 28. In particular, thebattery voltage for the front and rear pockets 24 and 26 is diode ORedby way of the diodes D₁ and D₂ to the P₂ terminal. Thus, the batterywith the largest voltage will control the power supply.

FIG. 2A represents an exemplary characteristic diagram for the DC--DCconverter circuit illustrating the DC--DC converter circuit voltage(i.e., the output of the power supply 28 on the P₁ terminal) on thevertical axis as a function of the highest sensed battery voltage on thehorizontal axis. Referring to FIG. 2A, the DC--DC converter circuitprovides a constant output voltage V₁, for example 7.5 volts, up to asensed battery of VBATT1, for example 6.1V. Above a battery voltage ofVBATT1, the power supply 28 produces coupled output, adding a fixedvoltage, for example 1.4V to the highest sensed voltage up to a secondpower supply voltage V₂, for example 10.5 volts which corresponds to abattery voltage VBATT2, for example 9.1 volts. Above VBATT2, the powersupply maintains a constant output voltage of V₂. An exemplary DC--DCconverter circuit is illustrated in FIG. 2B.

BATTERY CHARGER HARDWARE

The battery charger circuit 22 is illustrated in FIGS. 3A-3B. Thebattery charger circuit 22 is shown with circuitry for both a frontpocket 24 and rear pocket 26. At the heart of the battery chargercircuit 22 is a microcontroller 30. The microcontroller 30 may be afour-bit microcontroller, such as a Panasonic Series MN1500 described indetail in "MN1500 Series Four-Bit, One-Chip Microcomputers Users'Manual", published by Matsushita Electronics Corporation, hereinincorporated by reference. Other microcontrollers may also be suitable.The microcontroller 30 includes an on-board 256X4 random access memory(RAM), as well an on-board 4096X8 EEPROM for program instructions. Themicrocontroller 30 also includes a plurality of programmableinput/output ports P00-P13, as well as an internal hardware timer and anon-board analog to digital (A/D) converter with six A/D input/outputports AD0-AD5.

As will be discussed in more detail below, the system isinterrupt-driven. In particular, an internal interrupt counter generatesinterrupts at predetermined time periods to measure various batteryparameters, such as battery voltage, current and temperature, forexample, every 244 μsec.

In a two-pocket configuration, a time slice is allotted to each pocket24, 26 (context) so that the batteries in each pocket 24, 26 can bealternatively charged on a time division multiplex basis with constantcurrent or constant voltage, as opposed to known systems where thebattery in one pocket is fully charged before any charging begins on theother pocket. In order to prevent overdriving of the battery chargercircuit 22, the power dissipation is continuously checked on aninterrupt basis. In particular, the battery voltage VBATT is determinedby sensing the voltage across the voltage divider circuits R19/R21 andR25/26 and subtracting the voltage across the shunt resistors R24 andR28 for the front and rear pockets 24 and 26, respectively. The sensedbattery voltage VBATT is applied to an A-D port on the microcontroller30. The battery current is sensed by way of the sensing resistors R24and R28 connected in series with the batteries in the front and rearpockets 24 and 26, respectively. Any time the power dissipation foreither of the pockets 24, 26 becomes excessive, the respective powertransistors Q₁ and Q₄ under the control of a pulse width modulator (PWM)are operated to control the power dissipation to an acceptable level.

A plurality of light-emitting diodes, LED1, LED2, LED3, LED4, LED5 andLED6, are provided for each of the front pocket 24 and rear pocket 26.In particular, each pocket 24, 26 is provided with a red, yellow andgreen LED. These LEDs provide the status of the charging system. TheLEDs, LED1, LED2, LED3, LED4, LED5 and LED6 are connected between thevarious input/output ports on the microcontroller 30 and a powertransistor Q3. More particularly, the emitter terminal of the transistorQ3 is coupled to the LEDs, LED1, LED2, LED3, LED4, LED5 and LED6 by wayof a plurality of current-limiting resistors, R12, R14, R13, R15, R16and R17. The collector of the transistor Q3 is coupled to the positiveoutput terminal P1 of the power supply and AC adapter 28. The base ofthe transistor Q3 is tied high to cause the transistor Q3 to conductanytime the power supply and the AC adapter 28 is connected to a120-volt supply.

External power for the microcontroller 30 is developed by a linearregulator VR1, for example, a National Semiconductor Model LM 78L-05LZ,whose input terminal VCC is connected to the positive output P1 of thepower supply and AC adapter 28, which provides a 5.0+/-5% VDC supply forboth the analog and digital supply terminals AVDD and VDD of themicrocontroller 30, as well as an EEPROM 32, discussed below. In orderto provide a relatively constant voltage source to the microcontroller30, a capacitor C1 is tied at the output of the linear regulator R1 andground. In addition, a second capacitor, C2, is connected between thepower supply input VDD and ground. Both the analog and digital groundpins of the microcontroller 30 VSS and AVSS are tied directly to ground.

The microcontroller 30 is an 8 MHz device. The clock signal for themicrocontroller 30 may be provided by an 8 MHz crystal connected betweenits OSC1 and OSC2 pins. The reset pin (RST) is connected to ground byway of a capacitor C7, in order to prevent instantaneous fluctuations inthe reset signal. The reset terminal (RST) is also connected by way of aresistor R30 to a device to measure the power supply voltage, such as aSchmitt trigger, for example, as manufactured by Panasonic, Model No.MN1381.

The front pocket signals F-COMM, F-SIZE and F-THERM are pulled high byway of pull-up resistors R2, R6, and R20, respectively. The F-COMMsignal is applied to a serial input SDO of the microcontroller 30 by wayof an input resistor R5. The F-SIZE signal is applied to a serial inputpin SDT of the microcontroller 30 by way of an input resistor R7 and aserially coupled capacitor C3. The serial port SDO (or alternatively anI/O port) enables the battery charger circuit 22 to communicate withsmart battery packs as discussed above. The F-THERM signal, an analogsignal, is tied directly to an A/D input port AD1 of the microcontroller30.

The battery signals from the rear pocket 26, R-COMM, R-SIZE and R-THERMare connected to the microcontroller 30. In particular, the R-COMMsignal is connected to a bidirectional serial communication port SD1 onthe microcontroller 30 by way of an input resistor R23. The R-SIZEsignal from the rear pocket 26 is connected to an interrupt terminal IRQon the microcontroller 30, by way of an input resistor R18 and seriallycoupled capacitor C6.

Charging power is applied to the battery in the pockets 24, 26 by way ofthe -BATT+ and -GND signals. As such, the P₂ terminal of the powersupply 28 is connected to the positive battery terminal F-BATT-+ for thefront pocket 24 by way of a power transistor Q1F and a diode D4 as wellas to the positive battery terminal R-BATT-+ for the rear pocket 26 byway of a power transistor Q1R and a diode D3. The negative batteryterminal F-GND for the front pocket 24 is connected to ground by way ofa current sensing transistor R24 while the negative battery terminalR-GND for the rear pocket 26 is connected to ground by way of a currentsensing transistor R28.

The analog battery voltage VBATT for the front pocket 24 may be read byway of the F-BATT+ terminal, connected to an A/D input/output port AD3of the microcontroller 30 by way of a voltage divider consisting of theresistors R19 and R21. Similarly, the analog battery voltage VBATT forthe rear pocket 26 may be read by the R-BATT-+ terminal by way of avoltage divider consisting of the resistors R25 and R26, applied to theA/D input/output port AD4. As mentioned above, the system isinterrupt-driven and as such the microcontroller 30 may read variousparameters including the battery voltage VBATT, as well as the batterytemperature BATT TEMP and charge current, every interrupt cycle, forexample 244 μsec for both the front pocket 24 and rear pocket 26, whichenables batteries with different charging characteristics to be chargedat the same time.

Power to the batteries in the front and rear pockets 24, 26 is under thecontrol of a pair of power transistors Q1 and Q4, by way of a pair ofdiodes D4 and D3, respectively. The diodes D4 and D3 prevent thebatteries from backfeeding the circuitry during non-charging conditions.The power transistors Q1 and Q4 are under the control of a pair of pulsewidth modulators (PWM). The PWM for the front pocket 24 includes atransistor Q2, a capacitor C4 and a pair of resistors R8 and R9 whichdrives the power transistor Q1. The collector of the transistor Q2controls the power transistor Q1F for the front pocket 24. The PWM forthe rear pocket 26 includes a transistor Q5, a capacitor C5 and a pairof resistors R1 and R10. The collector for the transistor Q5 controlsthe power transistor for the rear pocket 26.

Both PWMs operate in real time and operate in essentially the samemanner. Thus, only one PWM will be described. Both PWMs are driven bythe microcontroller 30 and in particular the terminals Xo and X1, which,as used herein, is an input/output port. These outputs of the I/O portsXo and X1 are applied to the PWMs for the front and rear pockets 24 and26 respectively. In particular, the output of the PWMs is applied to thebase of the transistors Q2 and Q5 by way of current limiting resistorsR9 and R11 for the front and rear pockets 24 and 26, respectively.

The collector current of the PWM transistors Q2 and Q5 is used tocontrol the operating region of the power transistors Q1F and Q1R. Thecollector current of the PWM transistors Q2 and Q5 is under the controlof the RC circuit, connected between the emitter and base terminals.When the I/O port X₀, X₁ is high, the RC circuit begins charging anddischarging if the I/O part of X₀, X₁ is low as function of the and itsRC time constant. For exemplary values of the resistors R8 and R10 of100 ohms exemplary values for the capacitors C4 and C5 of 10 μf, thetime constant will be approximately 0.001 seconds. By selecting arelatively long time constant relative to the interrupt period 244 μsec,the PWM transistors Q2 and Q5 as well as the power transistors Q1F andQ1R will conduct all the time. The transistors Q1F, Q1R, Q2 and Q5 thusoperate in the linear region to control the power transistors Q₁ and Q₄to provide either constant current or constant voltage charging. Moreparticularly, the battery voltage VBATT and charging current IBATT arecontinuously monitored as discussed above. The PWMs control the powertransistors Q₁ and Q₄ to maintain either a constant voltage or constantcurrent.

In order to avoid the need to use precision components, an EEPROM 32 isprovided and used for storing calibration constants for the standardtolerance components used in the circuit. The EEPROM 32 may be a Xicor,for example, Model 24 with 16 bytes of storage space. As will beindicated in more detail below, one byte of the EEPROM 32 is providedwith a unique identifying number to indicate whether the calibrationconstants have been downloaded to the EEPROM 32.

BATTERY CHARGER SOFTWARE

The flow diagrams for the microcontroller 30 are illustrated in FIGS. 4through 15. For a two-pocket battery charger, the system treats thepockets independently. In particular, a flag is set for the activepocket to enable measurements and charging to be done for that pocket.Once the measurements and charging for the active pocket are complete,the flag is reset for that pocket and set for the other pocket to enablemeasurements and charging to be done for the other pocket.

There are various active states of the battery charger. Since themeasurements and charging of both pockets is virtually identical, theactive states are discussed for a single pocket battery charger.

POWER-UP STATE

Referring first to FIG. 4, the power-up routine is illustrated.Initially, on power-up, the PWM transistors Q2 and Q5 are turned off byway of the microcontroller 30. By turning off the PWM transistors Q2 andQ5, the power transistors Q1 and Q4, respectively, are turned off which,in turn, cuts off battery charging current to both the front and rearpockets 24, 26, as illustrated in step 50. In addition to turning offthe charging current to the front and rear battery pockets 24, 26, theLEDs, LED1, LED2, LED3, LED4, LED5 and LED6 for the front and rearpockets 24, 26 are initialized and turned off in step 52.

As will be discussed in more detail below, measurements of the batteryvoltage current and temperature are taken on an interrupt basis everypredetermined time interval. As such, the microcontroller 30 includes aninternal interrupt counter, set to interrupt the microcontroller 30 atpredetermined time periods, for example, every 244 μsec. At eachinterrupt period, the microcontroller 30 reads various parameters forboth of the front and rear pockets 24, 26 including the battery voltage,battery current and battery temperature. At power-up, the interruptcounter is initialized to zero in step 54.

The EEPROM 32 for the calibration constants is write-disabled duringinitialization. Also, the A/D ports, AD0-AD5, used for converting thebattery parameters to digital values, are set to be inputs. The stacktimer, as well as the internal RAM within the microcontroller 30, arealso initialized in steps 56 and 58. After power-up, the battery chargercircuit 22 goes through various states, as discussed below.

IDLE₋₋ INIT STATE

After power-up, the system goes into the idle-initiate state IDLE₋₋INIT, as indicated in step 60. In this state, the battery charger readsvarious calibration constants for the various types of batteries from anEEPROM 32. In addition to the calibration constants, the EEPROM 32 alsoincludes a unique number which indicates whether or not the calibrationconstants have been loaded into the EEPROM 32. Thus, in step 64, apredetermined byte, for example, the first byte which contains theunique number, is read. If the unique number is not found within theEEPROM 32, the system assumes that the EEPROM 32 does not include thecalibration constants and proceeds to step 66. In step 66, the LEDs,LED1, LED2, LED3, LED4, LED5 and LED6 are flashed at the a 2 Hz rate toindicate that the system EEPROM 32 does not contain the calibrationconstants. Subsequently, in step 68, the system returns to step 60.

If the EEPROM 32 is found to include the calibration constants, thesystem proceeds to step 70 to determine if a battery has been detectedin either the front pocket 24 or rear pocket 26. As mentioned above, themicrocontroller 30 includes an interrupt counter which initiatesdetection of various battery parameters, including the battery voltage,current and temperature for both the front pocket 24 and rear pocket 26,every predetermined time period, such as 244 μsec. If no battery isdetected, the system loops back to step 70 until a battery is detected.Once a battery is detected, a battery detection flag is set and thesystem attempts to read the EEPROM 32 in step 72. The first step inreading the EEPROM 32 is detecting the EEPROM 32 itself in step 74. Ifno EEPROM 32 is detected, the system goes to step 76 and utilizesdefault values. If an EEPROM 32 is detected, the constants are writtento the on-board RAM on the microcontroller 30 in step 78. Once thevalues are written to the RAM, the data is analyzed in step 79 todetermine if it is valid, for example, by way of a checksum. If not, thesystem loops to step 76 and uses default values. If the data is valid,the system goes to the pocket state REVAL₋₋ INIT in step 80.

REVAL₋₋ INIT STATE

The state REVAL₋₋ INIT is illustrated in FIG. 5. Initially, in theREVAL₋₋ INIT state, the pocket state is set in step 81, after which thesystem calls a subroutine MEASURE (FIG. 12) which measures the batteryparameters in the preselected interrupt intervals and stores them in themicrocontroller 30 RAM in step 82 as well as other battery informationincluding the battery size and type. These values are then compared withtable values stored in the on-board EEPROM on the microcontroller 30 forthe type of battery detected in the pocket. More particularly, thesystem checks to determine whether the battery voltage VBATT, asmeasured, is greater than VMAX, a value loaded into the EEPROM of themicrocontroller 30 in step 84, indicating maximum voltage for theparticular type battery. If so, the system proceeds to a pocket stateHIGHZ₋₋ INIT in step 86.

If the battery voltage VBATT is less than the stored maximum value VMAX,the system next utilizes the calibration constants from the EEPROM 32 toprovide temperature compensation of the measured battery voltage valueVBATT in step 88. Subsequently, the system determines in step 90 if thebattery voltage VBATT is less than a stored value VMIN, the minimumstored battery value. If so, the system proceeds to a pocket stateVMIN₋₋ INIT in step 92. It not, the system proceeds to step 94, wherethe minimum stored temperature value TEMP MIN is compared with themeasured value BATT TEMP. If the measured battery temperature value BATTTEMP is less than the stored value TEMP MIN, the system proceeds to apocket state TPEND₋₋ INIT in step 96. If not, the system checks in step98 whether the measured battery temperature BATT TEMP is greater than amaximum stored value TEMP MAX. If so, the system goes to state TPEND₋₋INIT in step 100. If the battery temperature is less than the storedvalue for TEMP MAX, indicating maximum temperature for the battery, thesystem next checks in step 102 to determine if the battery is a lithiumion battery. More particularly, lithium ion battery packs normallyinclude an internal EEPROM, which include data which indicates that thebattery is a lithium ion type. As mentioned above, such data from thebattery pack EEPROM is stored in state IDLE₋₋ INIT. If so, the systemproceeds to lithium rapid initiation state in step 104. If not, thesystem assumes that the battery is a nickel metal hydride (NiMH) or anickel cadmium (NiCd) battery, which merely require constant currentcharging in step 106 and proceeds to a NICK₋₋ RAPID₋₋ INIT state.

TPEND₋₋ INIT STATE

The TPEND₋₋ INIT pocket state is illustrated in FIG. 6. As indicatedabove, the system enters the TPEND₋₋ INIT state from steps 94 or 98,depending on whether the measured battery temperature BATT TEMP is lessthan the minimum TEMP MIN or greater than the maximum temperature TEMPMAX, stored in the on-board EEPROM in the microcontroller 30. The systemremains in this state until the measured battery temperature BATT TEMPis within the proper limits (i.e., TEMP MIN<BATT TEMP<TEMP MAX). Inorder to provide relative stable operation of the system, hysteresis maybe provided around the temperature constants such as TEMP MIN and TEMPMAX.

Initially, in step 108, the pocket state of the battery charger 22 isstored. After the state of the battery charger 22 is stored, the systemsets the yellow LEDs LED2 or LED5, depending on the measured temperaturein the particular pocket, front 24 or rear 26, in step 110. In step 112,the yellow LEDs are flashed at a 2 Hz rate to indicate that the measuredbattery temperature, either for the front 24 or rear pocket 26, is outof the proper temperature operating range. After flashing the yellowLEDs, LED2 and LED5, the system continues checking battery measurementsof the front 24 and rear pocket 26, in step 114 by way of the MEASUREsubroutine, discussed below. The system checks, in step 116, todetermine if the measured battery temperature BATT TEMP is greater thanthe minimum temperature TEMP MIN. If not, the system continues readingbattery temperature BATT TEMP until the measured battery temperatureBATT TEMP is greater than the minimum recommended battery temperatureTEMP MIN. Once the measured battery temperature BATT TEMP is found toexceed the minimum temperature TEMP MIN, the system next checks in step118 to determine if the measured battery temperature BATT TEMP is lessthan the maximum temperature TEMP MAX. If not, the maximum temperatureof the battery is assumed to be exceeded and the system stays in theloop, checking the measured temperature BATT TEMP until the measuredbattery temperature BATT TEMP drops down below the maximum temperatureTEMP MAX. If the measured temperature BATT TEMP is found to be less thanthe temperature maximum TEMP MAX measured in step 118, the systemreturns to the REVAL₋₋ INIT state in step 120, as discussed above.

HIGHZ₋₋ INIT STATE

The HIGHZ₋₋ INIT state is illustrated in FIG. 7. As indicated above, thebattery charger 20 enters this state when the measured battery voltageVBATT is found to be greater than a maximum voltage VMAX. In this state,the system initially sets the pocket state as the HIGHZ₋₋ INIT state instep 122. After the pocket state is set, the green LEDs, LED3 and LED6,are set in step 124, to indicate that the battery voltage VBATT isgreater than the maximum voltage VMAX. Since the measured batteryvoltage VBATT exceeds the maximum battery voltage VMAX recommended, allcharging current to the active pocket 24, 26 is turned off in step 126by turning off the respective PWM transistors Q2 and Q5, which, in turn,turns of f the series power transistors Q1F and Q1R, respectively. Afterthe current to the active pocket 24, 26 is turned off, the systemcontinues to make temperature measurements as long as a battery pack isdisposed in either the front or rear pocket 24, 26, respectively. Oncethe system determines in step 130 that a battery pack is no longercontained in either the front pocket 24 or rear pocket 26, the systemgoes to the state IDLE₋₋ INIT, as discussed above.

As discussed below, the determination of whether a battery pack isavailable in either the front or rear pocket 24, 26, is made by makingvoltage measurements and comparing these measurements with the valuesstored in the EEPROM on board the microcontroller 30. Should thesevalues indicate no battery is present, the system will return to theIDLE₋₋ INIT state, awaiting another battery pack to be inserted into thebattery charger 20 in step 132.

VMIN STATE

The VMIN₋₋ INIT state is illustrated in FIGS. 8A and 8B. As indicatedabove, the system goes to the VMIN state any time the measured batteryvoltage VBATT is determined to be less than a minimum voltage VMIN. Whenthe battery is in such a state, the battery charger state is stored instep 134 and the battery is first preconditioned with a trickle chargebefore entering into a fast charge state in order to avoid damage to thebattery. In this state, the yellow LEDs, LED2 and LED5, are flashed at a2 Hz rate in step 138. Subsequently, in step 140, the maximum voltageVMAX, from the table in the EEPROM on board the microcontroller 30 isstored in the on-board RAM in step 142. Subsequently, in step 144, thetrickle current value from the table is obtained in step 144 and storedin step 146. In step 148, the system is set to trickle charge thebattery in either the front pocket 24 or rear pocket 26 by way ofcontrol of the PWM driver transistors Q2 and Q5, which, as mentionedabove, drive the power transistors Q1 and Q4 to supply the tricklecharge current to battery packs disposed in the front or rear pockets24, 26, respectively. In step 150, the measured battery parameters arestored in the on-board RAM on the microcontroller 30. The measuredbattery voltage VBATT is compared with the maximum voltage VMAX for thebattery in step 152. If the measured battery voltage VBATT is greaterthan the maximum voltage VMAX, the system goes to the HIGHZ₋₋ INIT statein step 154, as discussed above. If the measured battery voltage VBATTis determined not to be greater than the maximum voltage VMAX, thesystem proceeds to step 156 and obtains the minimum battery voltage VMINfrom the table. In order to avoid cycling, hysteresis is added by addinga predetermined number, for example, 117 mV, to the minimum voltagevalue VMIN in step 158. The new value is stored in step 160. In step162, the measured battery value VBATT is temperature compensated by wayof a parameter value retrieved from the battery EEPROM or defaulttables. Subsequently, the temperature-compensated battery voltage VBATTis compared with the minimum voltage to determine if the battery voltageVBATT is greater than the temperature-compensated minimum batteryvoltage in step 164. If so, the system proceeds to the pocket stateREVAL₋₋ INIT (FIG. 5). If not, the system returns back to step 150 andcontinues trickle charging the battery and checking the battery voltageVBATT. Once the measured battery voltage VBATT becomes greater than theminimum battery voltage, the system goes to step 166, which returns toREVAL₋₋ INIT state.

NICK₋₋ RAPID₋₋ INIT STATE

The flow diagram for rapid charging for nickel cadmium (NiCd) and nickelmetal hydride (NiMH) batteries is identified as NICK₋₋ RAPID₋₋ INIT andis shown in FIGS. 9A, 9B and 9C. In this state, once the systemdetermines that the battery in either the front pocket 24 or rear pocket26 is not a lithium ion battery, the system goes to the NICK₋₋ RAPID₋₋INIT state, assuming that the battery temperature BATT TEMP is less thanthe maximum temperature TEMP MAX. In this state, the pocket state isinitially set as the NICK₋₋ RAPID₋₋ INIT state, indicating rapid chargefor nickel metal hydride (NiMH) and nickel cadmium (NiCd) batteries instep 168.

In addition to the hardware interrupt counter discussed above, thesystem utilizes three software timers: a gas gauge timer; a ΔT timer anda safety timer. The gas gauge timer is used for timing both rapid andtrickle charging of batteries requiring constant current charging, suchas nickel cadmium and nickel metal hydride batteries. The storedcharging values are retrieved for such batteries to cause the batteriesto be charged at the stored values. After the pocket state is stored,the gas gauge timer within the microcontroller 30 is initiated in step170. After the gas gauge timer is initiated in step 170, a plurality ΔTregisters in the microcontroller 30 are cleared in step 172. Since bothnickel metal hydride (NiMH) and nickel cadmium (NiCd) batteries aresubject to a maximum temperature change per unit of time, stored ΔTtimer values are retrieved from the table in step 174 and loaded intothe ΔT timer in step 176. After the ΔT timer is initiated with the ΔTtimer value, the red LEDs, LED1 and LED4, are set in step 178. Thesafety timer is set, for example, to a relatively long period, forexample, a few hours. The safety timer returns the battery to a tricklecharge after a predetermined time period irrespective of the rate ofchange of temperature with time of the battery. Thus, in step 180, thetime period for the safety timer is retrieved from the table in step 180and loaded into the safety timer in step 182. Subsequently, in step 184,the maximum allowable voltage VMAX is obtained from the table in step184 and stored in 186. The maximum charging current IMAX is obtainedfrom the table in step 188 and used in step 190 for setting the PWMcontrol circuits, which, in turn, control the power transistors Q1 andQ4 for controlling charging current to the front and rear pockets 24,26. The current is checked in step 192. Subsequently, in step 194, thesystem charges the battery with the current IMAX. The system thenmeasures the current in step 196 to determine if the charging currentrequired by the rapid charge can be delivered by the system. Thus, instep 200, the system checks whether the charge current is 75% of thatrequested. If not, the system continues looping until the system candeliver at least 75% of the required rapid charge current. Should thesystem decide in step 200 that at least 75% of the required rapid chargecurrent can be delivered to either the front or rear pockets 24, 26, thesystem proceeds to step 202 and checks the safety timer. If the safetytimer has expired, the system goes to step 204 and goes to the NICK₋₋TRICKLE₋₋ INIT state for trickle charging both nickel metal hydride(NiMH) and nickel cadmium (NiCd) batteries. If the safety timer has notexpired, a predetermined value, for example, 300 mv, is added to themaximum voltage VMAX for the battery in step 206 to generate a cut-offvoltage value CUT-OFF₋₋ VOLTS. Subsequently, in step 208, the systemchecks if the battery voltage is greater than VMAX, the cut-off voltageCUT-OFF₋₋ VOLTS. If so, the system goes to the HIGHZ state in step 210.If not, the system proceeds to step 212 where the battery temperaturecompensation is determined for the measured battery voltage. In step214, the system determines whether the temperature-compensated batteryvoltage determined in step 212 is less than the minimum battery voltageVMIN. If so, the system proceeds to step 216 to the VMIN₋₋ INIT state.If not, the system goes to step 218 and checks whether thetemperature-compensated battery voltage value is greater than VMAX. Thesystem then checks in step 219 whether the safety timer five minute flaghas been set. If so, the system goes to the maintenance state MTCE (FIG.11) in step 221. If not, the system goes to step 220 to the NICK₋₋TRICKLE₋₋ INIT state for trickle charging both nickel metal hydride(NiMH) and nickel cadmium (NiCd) batteries. If not, the system goes tostep 222 which checks whether the rate of change of temperature per unitof time is greater than the value from the table. If so, the system goesto step 224 to the NICK₋₋ TRICKLE₋₋ INIT state. If not, the temperaturecut-off is determined in step 226. The system next checks in step 228 todetermine if the battery temperature BATT TEMP is greater than themaximum temperature TEMP MAX. If so, the system goes to the tricklecharge state NICK₋₋ TRICKLE₋₋ INIT in step 230. If not, the systemchecks in step 232 whether the measured temperature BATT TEMP is lessthan the minimum temperature TEMP MIN. If so, the system goes to theTPEND₋₋ INIT state in step 234. If the measured temperature BATT TEMP isnot less than the minimum temperature TEMP MIN, the gas gauge timer ischecked in step 236. If the gas gauge timer is not timed out, the systemcontinues with rapid charging and proceeds to step 242. Otherwise, thesystem does gas gauge checking as illustrated in FIGS. 9D and 9E.

Referring to FIG. 9D, the gas gauge checking is initiated in step 231 bychecking and calculating the allowable current to prevent damage to thepower supply and to the power transistors Q₁ and Q₄. In particular,power dissipation of the power supply 28 and the power transistors Q₁and Q₄ is checked. The power supply 228 may have an exemplary 850milliamp maximum while the power transistors Q₁ and Q₄ may be subject toan exemplary 2-watt power dissipation limit. The maximum powerdissipation levels (i.e., maximum battery current) is compared with atable value from the EEPROM 32 during gas gauge periods.

In step 233, a pocket priority flag is set. After the pocket priorityflag is set, the system determines in step 235 whether the requiredcharging current will exceed the maximum allowable current of the powersupply 228. If not, the yellow LEDs are set to flash at a 2 hertz ratein step 239. Additionally, the priority flag is cleared in step 241.Once the priority flag is set, the other pocket is kept off as discussedabove. The system then proceeds to step 243, assuming nickel typebattery compares maximum allowable current for the power supply 28 witha value representative of seventy five percent (75%) of the requiredcurrent to the active pocket. In other words, if the allowable currentfrom the power supply 28 is greater than seventy five percent (75%) ofthe required current, the system proceeds to step 245 and sets a new gasgauge period and then returns in step 247. If not, the LEDs are flashedat a 2 Hz rate in step 249. If the current required by the active pocketcan be sufficiently supplied by the power supply 28, the gas gauge timeris loaded in step 245 and measurements are made in steps 251 and 253until the gas gauge timer has expired. Once the gas gauge timer expires,the priority flag is cleared in step 255. The system them checks in step257 whether the battery voltage BATT is greater than a value LIM1,obtained from the EEPROM 32. If not, the system proceeds to step 253. Ifso, the system proceeds to step 259 and sets the red and yellow LEDs andagain checks in step 261 whether the battery voltage BATT is greaterthan a second value LIM2 obtained from the EEPROM 32. If not, the systemthen returns to step 243, otherwise, the red LED is set.

NICK₋₋ TRICKLE₋₋ INIT STATE

The flow chart for the NICK₋₋ TRICKLE₋₋ INIT state is illustrated inFIGS. 10A and 10B. Initially, in step 244, the trickle timer isinitiated. After the trickle timer is initiated, the yellow LED2, LED5and green LED3 and LED6 LEDs are set in step 246 to indicate tricklecharge. After the LEDs are set, the current level for trickle chargingof the battery is set in step 248. The current level is retrieved from atable value. In step 250, the pocket state is set to NICK₋₋ TRICKLE₋₋INIT.

The system normally tracks the peak voltage of the battery and storesthis voltage as PEAK VOLTS. In order to determine if the battery voltageis dropping, the PEAK VOLTS value is cleared in step 252. The systemnext enters into a trickle charge loop in which the current is checkedin steps 254 and 256. In steps 258 and 260, the battery temperature BATTTEMP is checked to determine if it has gone above the maximumtemperature permissible, TEMP MAX, or below the minimum temperaturepermissible, TEMP MIN. If the battery temperature is greater than themaximum temperature permissible, TEMP MAX, or less than the minimumtemperature permissible, TEMP MIN, the battery current is turned off insteps 262 and 264, respectively, and the system loops back to step 254and checks the current and continuously loops until the batterytemperature is within range. After the battery temperature is checked insteps 250 and 260 and found to be within the minimum and maximumtemperature range, the battery voltage is checked in step 266 todetermine if the current battery voltage is greater than the cut-offvoltage CUT-OFF VOLTS, a stored table value for the trickle charge stateindicating the maximum allowable voltage. If the battery voltage isgreater than the cut-off voltage CUT-OFF VOLTS, the system goes to theHIGHZ state, as indicated in step 266. If the battery voltage is notgreater than the cut-off voltage CUT-OFF VOLTS, the system next checksin step 270 to determine if the battery voltage is greater than the peakvoltage PEAK VOLTS. If so, the battery voltage VBATT is set to equal thepeak voltage PEAK VOLTS in step 272. If not, the system checks in step274 to determine if the battery voltage VBATT is less than the peakvoltage PEAK VOLTS. If so, the system goes to the REVAL₋₋ INIT state instep 276. If not, the system proceeds to step 278 to determine if thetrickle timer has expired. If so, the system goes to a maintenancecharge state MTCE₋₋ INIT in step 280. If not, the system checks to seeif the gas gauge timer expired in step 282. If so, the system does a gasgauge as discussed above and continues trickle charging in step 284.

MTCE₋₋ INIT STATE

The flow chart for the maintenance charge state MTCE₋₋ INIT of thebattery is illustrated in FIGS. 11A and 11B. Initially, in this state,the green LEDs, LED3 and LED6, are set in step 286 to indicate that thecharger is in a maintenance charge mode. After the green LEDs are set,the maintenance current level is set in step 288 and the pocket state isinitiated for maintenance state in step 290. After the pocket state isset in step 290, a maintenance timer is initiated for 30 seconds, forexample, in step 292. The battery temperature in the front and rearpockets 24, 26 is measured in step 294 by way of the F-THERM and R-THERMsignals, applied to the A-D input ports on the microcontroller 30 instep 294. The measured values of the battery temperature BATT TEMP arethen compared with the minimum and maximum values from the table insteps 296 and 298. Should the battery temperature BATT TEMP eitherexceed the maximum temperature, TEMP MAX or be less than the minimumtemperature TEMP MIN, the current is immediately set to zero in steps300 and 302, respectively, and the system loops back to step 294 untilthe temperature returns to the recommended range between the maximumTEMP MAX and minimum TEMP MIN temperature values. Once the batterytemperature is within the recommended temperature range, the systemproceeds to step 306 and checks if the battery is in a HIGHZ conditionin which the current is turned off and the thermistors are checked todetermine if they are applicable (see FIG. 15). After the thermistorsare checked, the system then checks in step 308 to determine if the30-second maintenance timer delay has expired. If not, the system loopsback to step 294 and continues checking the temperature. Once themaintenance timer has expired, the system initializes the peak voltagevalue in step 310 and sets a peak voltage flag in step 312. After thepeak voltage value is initialized, the system checks in step 314 todetermine if the battery voltage is less than the peak voltage minus avalue from the battery or default tables. If so, the battery voltage isassumed to drop to a level requiring trickle charging and the systemproceeds to the nickel charge mode NICK₋₋ TRICKLE₋₋ INIT in step 316. Ifnot, the system proceeds to step 318 and determines if the gas gaugetimer is expired. If not, the system loops back to step 294 andcontinues a maintenance charge on the battery while checking thetemperature level. If so, charging is discontinued in step 320.

MEASURE

The flow chart for the subroutine MEASURE is illustrated in FIGS.12A-12C. As mentioned above, the system is interrupt-driven by way of aninternal hardware counter on board the microcontroller 30. The interruptcounter is used to interrupt the microcontroller 30 and read the batteryparameter values for the front and rear pockets 24, 26, respectively. Inparticular, the battery voltage VBATT, current IBATT, and temperaturelevel BATT TEMP for each of the pockets 24, 26 is continuously andalternatively read by the system on an interrupt level. In addition torequesting the various battery values, thermistor and currents to beread, the MEASURE subroutine also swaps contexts (alternates betweenpockets on a time division multiplex basis) at predetermined timeslices, for example, every 62.5 milliseconds.

Referring to FIG. 12, the MEASURE subroutine first checks the pocketstate to determine whether it is in an idle state in step 322. If thesystem is in an idle state, the measure counter is set to 8 in step 324to enable four measurements to be made for each of the front and rearpockets 24, 26 to be made in a row in order to determine whether thereare batteries in these pockets. If the system is not in an idle state,the measure counter is set to zero in step 326. As mentioned above inconnection with the idle state, the system ascertains whether a batteryis present in each of the front and rear pockets 24, 26.

Measurements are made on an interrupt basis. An interrupt is generatedat every predetermined interrupt period, for example, 244 μsec. As willbe discussed in more detail below, the MEASURE subroutine initiatesbattery parameter measures at every interrupt for a predetermined numberof interrupts; for example, 64 sets of measurements are taken to providean average value. Each time a set of 64 measurements is made, a measurecounter is incremented. Measurements are made for a predetermined numberof counts on the measure counter, for example, 4. Thus, with theexemplary parameters discussed above, a time slice is defined as 64measurements×4 loops×0.244 μsec., or about 62.5 milliseconds; the amountof time allotted to each pocket 24, 26. Since base level measurementswill be alternatively made in both the front and rear pockets 24, 26,the time slices for the particular pockets are synchronized in step 328.In other words, the interrupt counter for the active pocket is set tozero and the contexts (i.e. pockets) are swapped. After the time sliceis initialized in step 328, previously read battery values, such as thevoltage, thermistor and current values, are cleared from the system RAMin step 330. Once the previously read values are cleared, a measure flagis set in step 332 to indicate that the thermistor measurements for thatcontext or pocket are to be taken. Once the measure flag is set, theinterrupt counter is loaded in step 334. The interrupt counter is usedfor the A-D conversions. In particular, the interrupt timer allows 64sets of A-D conversions to be made in step 336. The system continueslooping until all 64 A-D conversion measurements have been made.Subsequently, in step 338, the measure flag is reset and the normalizedvalues for the measured battery voltage and temperature are calculatedin step 340. The constants from the EEPROM 32 (i.e., slope and offsetvalues) (32) are factored into the measurements of the battery voltageVBATT and temperature measurements. Subsequently, in step 342, thesystem determines whether the battery temperature is less than -30° C.If so, the system determines in step 344 whether a battery was detectedpreviously for the active pocket, by checking the battery detection flagindicating a battery present for that pocket. If no batteries havepreviously been detected, the system proceeds to step 346. If a batterywas previously detected, the system resets the battery detection flag instep 348 before proceeding to step 346. As mentioned above, the systemnormally makes four loops to detect if a battery is present. Thus, oncea battery is detected, the battery detection loops are reset. Asmentioned above, the system makes loops for about four measurements.Thus, in step 346, the measure counter is incremented. In step 348, thesystem determine whether four sets of measurements have been taken. Ifnot, an additional 64 A-D conversions are made in step 350. If all themeasurements have been made, the battery voltage measurements are scaledin step 352 and the system goes to the idle state in step 354.

If the system determine in step 342 that the battery temperature is≧-30° C., the system checks the pocket state in step 356 to determine ifthe system is in an idle state. If the system is in an idle state, thesystem checks in step 358 whether the battery detection flag has beenset. If the battery detection flag has been set, the measure counter iscleared in step 360. If the battery detection flag has not been set, itis set in step 362 and the measure counter is incremented in step 364 toenable additional sets of 64 A-D measurements to be taken, until foursets of measurements have been taken, as indicated in steps 366 and 368,as discussed above. Once all the measurements are taken, the batteryvoltage is scaled in step 370. After the battery voltage measurementsare scaled, the system checks in step 372 to determine whether thebattery flag has been set. If not, the system goes to the idle state instep 374. If so, the system checks in step 376 whether the system is inthe idle state. If not, the system returns in step 378. If the batteryis in the idle state, a reading of the EEPROM in the battery pack isattempted in step 380. As indicated above, the battery pack EEPROMcontains various information regarding the battery type and sizeavailable to the system over the -COMM and -SIZE terminals. Thus, instep 382, the system checks whether the battery pack EEPROM is present.If the battery pack EEPROM is present, the system checks whether thebattery is a lithium type battery in step 384. If so, a bit is set instep 386 to indicate that the battery is a lithium type and the systemgoes to the LITH₋₋ RAPID₋₋ INIT state (FIG. 13A). If it is ascertainedfrom the data read from the battery packEEPROM that the battery is not alithium type, the system assumes that the battery is a nickel cadmium(NiCd) nickel metal hydride (NiMH) type battery and then attempts toread the size of the battery in step 388. As mentioned above, for smartbattery packs, the battery charger 22 communicates with the battery packby way of the -SIZE and -COMM terminals. Thus, once it is determined instep 388 that the battery is a nickel type battery, the systemdetermines in step 390 whether the nickel battery is a large batteryi.e., a battery where the -SIZE pin is shorted to the -BAT-+ line. If itis determined that the battery is not a large battery, a slim battery isassumed, and the system returns in step 392. If the battery is a largebattery, a bit indicating a large battery is set in step 394, afterwhich the program returns in step 396.

As mentioned above, the system determines the pocket state of thecharger in step 356. If the pocket state is determined to not be in anidle state in step 356, the system checks in step 398 whether the otherbattery pocket or context has priority. If so, the system jumps back tothe beginning of the measure subroutine in step 400, i.e., will notreturn from measure if the other pocket has priority. If the currentpocket has priority, the measure counter is incremented in step 402. Asmentioned above, four sets of measurements are made for the activepocket. Thus, in step 404, the system determines whether or not all foursets of measurements have been made. If not, the system gets additionalmeasurements in step 406. If all of the measurements have been made,they are scaled in step 408, and the values are returned in step 410.The process is then repeated for the other pocket.

LITH₋₋ RAPID₋₋ INIT STATE

The flow charts for the LITH₋₋ RAPID₋₋ INIT STATE are illustrated inFIGS. 13A-13B. Referring first to FIG. 13A, the pocket state for theLITH₋₋ RAPID₋₋ INIT STATE is loaded initially in step 412. After thepocket state is loaded in step 412, all timers are cleared in step 414,and the maximum voltage for the lithium battery is selected from thetables stored in the battery EEPROM 32 in step 416. The charge rate N₋₋RAPID₋₋ INIT obtained from the table in the EEPROM 32 is also read fromthe table in step 418. After the voltage and the charge rate have beenselected, the current is set in step 420. Once the charging rate is set,the system calls the MEASURE subroutine in step 420 to makemeasurements, as discussed above, in order to enable the system to checkwhether the battery voltage VBATT is greater than the cut-off volts plusa constant in step 424. If the battery voltage is greater than thecut-off volts plus a constant, the system goes to the HIGHZ state instep 426. Otherwise, the system checks the gas gauge timer to determinewhether it has expired in step 428. If the gas gauge timer has notexpired, the system loops back to step 412. Otherwise, the time constantfrom the table for the gas gauge timer is loaded in step 432. Once thegas gauge timer is loaded, the red LED is turned on in step 434. Thesystem then checks whether the battery voltage is greater than aconstant N₋₋ GAS₋₋ LIM1. If not, the system loops back in step 436. Ifthe battery voltage is not greater than the constant N₋₋ GAS₋₋ LIM1, thesystem loops back to step 412. Otherwise, the red and yellow LEDs areset in step 440, after which the system checks in step 442 whether thebattery voltage is greater than a second constant N₋₋ GAS₋₋ LIM2. If thebattery voltage is less than the second voltage limit N₋₋ GAS₋₋ LIM2,the system loops back to step 412. Otherwise, the yellow LEDs are set instep 446, after which the system checks the current. More particularly,in step 446, the system checks whether the current is greater than apredetermined value. If so, the system loops back to step 412.Otherwise, the yellow and green LEDs are set in step 450. Once theyellow and green LEDs are set, the system checks in step 452 whether thecurrent is greater than a second constant N₋₋ GAS₋₋ 95. If not, thegreen LEDs are set in step 454, and the system loops back to step 412.If the current is greater than the constant N₋₋ GAS₋₋ 95, the systemloops back to step 412 and step 458.

INTERRUPT

The flow chart for the interrupt routine is shown in FIGS. 14A and 14B.As mentioned above, the system is interrupt driven. Referring first toFIG. 14A, the battery voltage and current inputs are connected to theA-D ports on the microcontroller 30. The interrupt routine does bothcurrent and voltage regulation for both the front and rear pockets 24,26, respectively. The interrupt routine also causes voltage measurementsfor the battery, as well as thermistor and resistor node measurements tobe made for each of the pockets. After the A-D process is initiated, theinterrupt counter is incremented in step 470. The TEMP VOLTS₋₋ HIGHvalue, which represents A-D conversion result registers is cleared instep 472 and a flag to turn on the A-D converters, as discussed above,is set in step 474. The system then continues looping in step 476 untilthe A-D conversion process is complete. Once the A-D process iscomplete, the A-D results registers values are stored as TEMP₋₋ VOLTS₋₋LOW and TEMP₋₋ VOLTS₋₋ MID in step 478 after the conversion process forthe front pocket in step 480. The system then checks in step 482 whetherthe current for the front pocket 24 is greater than the MAX current readfrom the table in the battery pack EEPROM in step 482. If so, the PWMflag is reset in step 484, thereby turning off the PWMS, which, in turn,disconnects the charging current from the battery source. Subsequently,in step 486, the front pocket priority flag is reset in step 486 toreset. If the current is greater than the maximum current from thetable, any requested base level measurements are made in step 488 andconverted to battery voltage in step 490, by summing it with the nodevolts. The process as described above is repeated for the rear pocket26.

CHECK HIGHZ

As discussed above, during certain conditions, a CHECK₋₋ HIGHZsubroutine is called in order to determine whether the thermistors arestill providing accurate output levels. The CHECK₋₋ HIGHZ subroutine isillustrated in FIG. 15. Initially, in step 500, a value for the maximumbattery voltage VMAX is read from the table in step 500. Once the valuefrom the table for VMAx is read in step 500, the actual battery voltageis measured in step 502 in a manner as discussed above. An offset isadded to VMAX in step 504, after which the battery voltage is comparedwith VMAX in step 506. If the battery voltage is greater than VMAX plusa constant, the system is assumed to be in a HIGHZ state. As such, thecurrent is shut off in step 508 and the system goes to the HIGHZ₋₋ INITstate in step 510. Alternatively, the system returns in step 512.

SOURCE CODE

The source code for the system is provided in an Appendix. It should beunderstood that the flow charts are merely simplified representations ofthe source code for purposes of describing and illustrating theoperation of the system. In the event of a conflict between the sourcecode and the flow charts, the source code prevails.

Obviously, many modifications and variations of the present inventionare possible in light of the above teachings. Thus, it is to beunderstood that, within the scope of the appended claims, the inventionmay be practiced otherwise than as specifically described above.##SPC1##

What is claimed and desired to be secured by Letters Patent of theUnited States is:
 1. A battery charger connected to a predeterminedpower supply for providing constant current and constant voltagecharging, the battery charger comprising:a power transistor connectedbetween the power supply and a battery to be charged; means for sensingthe power dissipation of said power transistor; and means forcontrolling said power transistor to provide constant current andconstant voltage to said battery to be charged as a function of thepower dissipation of said power transistor.
 2. A battery charger asrecited in claim 1, wherein said sensing means includes means forsensing the power dissipation of said power supply and wherein saidcontrolling means includes means for controlling said power transistoras a function of the power dissipation of said power supply.
 3. Abattery charger connected to a predetermined power supply for providingconstant current and constant voltage charging, the battery chargercomprising:a power transistor connected between the power supply and abattery to be charged; means for sensing the power dissipation of saidpower transistor, said sensing means including means for sensing thepower dissipation of said power supply; and means for controlling saidpower transistor to provide constant current and constant voltage tosaid battery to be charred as a function of the power dissipation ofsaid power transistor, wherein said controlling means includes a pulsewidth modulator (PWM) and means for receiving a predetermined inputsignal.
 4. The battery charger as recited in claim 3, wherein saidcontrolling means includes a transistor having base, collector andemitter terminals, a resistor and a capacitor, said resistor andcapacitor defining an RC time constant.
 5. The battery charger asrecited in claim 3, wherein said predetermined input signal is a signalgenerated at predetermined time periods.
 6. The battery charger asrecited in claim 5, wherein said RC time constant is selected to berelatively larger than said predetermined time period.
 7. A multipocketbattery charger connected to a predetermined power supply, the batterycharger comprising:a first pocket for receiving a first battery; a firstpower transistor connected between said power supply and said firstpocket; means for controlling said first power transistor to provide aconstant current output to said first pocket; a second pocket forreceiving a second battery; a second power transistor connected betweensaid power supply and said second pocket; means for sensing the powerdissipation of said power supply; and means for controlling said firstpower transistor and said second power transistor so that the electricalpower to said first pocket and said second pocket as a function of thepower dissipation of said power supply.
 8. The multipocket batterycharger as recited in claim 7, wherein said sensing means includes meansfor sensing the power dissipation of said first power transistor or saidsecond power transistor, said controlling means including means forcontrolling said first power transistor or said second power transistoras a function of the power dissipation of said first power transistor orsaid second power transistor, respectively.
 9. The multipocket batterycharger as recited in claim 7, further including means for controllingsaid first power transistor to provide a constant voltage output to saidfirst pocket.
 10. A multipocket battery charger connected to apredetermined power supply, the battery charger comprising:a firstpocket for receiving a first battery; a first power transistor connectedbetween said power supply and said first pocket; a second pocket forreceiving a second battery; a second power transistor connected betweensaid power supply and said second pocket; means for sensing the powerdissipation of said power supply; and means for controlling said firstpower transistor and said second power transistor so that the electricalpower supplied to said first Docket and said second pocket is a functionof the power dissipation of said power supply, wherein said controllingmeans includes a pulse width modulator (PWM), said PWM having means forreceiving a predetermined input signal.
 11. The battery charger asrecited in claim 10, wherein said controlling means includes atransistor having base, collector and emitter terminals, a resistor anda capacitor, said resistor and capacitor defining an RC time constant.12. The battery charger as recited in claim 10, wherein saidpredetermined input signal is a signal generated at predetermined timeperiods.
 13. The battery charger as recited in claim 11, wherein said RCtime constant is selected to be relatively larger than saidpredetermined time period.
 14. A battery charger connected to apredetermined power supply for providing constant current and constantvoltage charging, the battery charger comprising:a power transistorconnected between the power supply and a battery to be charged; meansfor sensing the power dissipation of said power supply; and means forcontrolling said power transistor to provide constant current andconstant voltage to said battery to be charged as a function of thepower dissipation of said power supply.
 15. A battery charger connectedto a predetermined power supply for providing constant current andconstant voltage charging, the battery charger comprising:a powertransistor connected between the power supply and a battery to becharged; means for sensing the power dissipation of said power supply;and means for controlling said power transistor to provide constantcurrent and constant voltage to said battery to be charged as a functionof the power dissipation of said power supply, wherein said controllingmeans includes a pulse width modulator (PWM) and means for receiving apredetermined input signal.
 16. The battery charger as recited in claim15, wherein said controlling means includes a transistor having base,collector and emitter terminals, a resistor and a capacitor, saidresistor and capacitor defining an RC time constant.
 17. The batterycharger as recited in claim 15, wherein said predetermined input signalis a signal generated at predetermined time periods.
 18. The batterycharger as recited in claim 16, wherein said RC time constant isselected to be relatively larger than said predetermined time period.